unit uInNomineCharacter;

interface

uses
  uInNomineSystem, Contnrs;

type
  TInNomineCharacter = class
  private
    FForces: array [0..2] of TForces;

    function getStrength(): TAttributeValue;
    function getAgility(): TAttributeValue;
    function getIntelligence(): TAttributeValue;
    function getPrecision(): TAttributeValue;
    function getWill(): TAttributeValue;
    function getPerception(): TAttributeValue;

    function getNumberForces(): integer;
    
    function getForces(index: integer): TForces;
    procedure setForces(index: integer; const value: TForces);
  public
    name: string;
    concept: PCharacterConcept;
    celestialKind: PCelestialKind;
    superior: TSuperior;
    essencePoints: TEssence;
    dissonancePoints: TDissonance;
    distinctions: TObjectList;
    resources: TObjectList;
    word: string;
    resourcePoints: integer;
    characterPoints: integer;

    constructor Create;
    destructor Destroy; override;

    property forces[index: integer]: TForces read getForces write setForces;

    property corporealForces: TForces index 0 read getForces write setForces;
    property etherealForces: TForces index 1 read getForces write setForces;
    property celestialForces: TForces index 2 read getForces write setForces;

    property strength: TAttributeValue read getStrength;
    property agility: TAttributeValue read getAgility;
    property intelligence: TAttributeValue read getIntelligence;
    property precision: TAttributeValue read getPrecision;
    property will: TAttributeValue read getWill;
    property perception: TAttributeValue read getPerception;
    
    property numberForces: integer read getNumberForces;
  end;

implementation

uses
  SysUtils;

{ TInNomineCharacter }

constructor TInNomineCharacter.Create;
begin
  name := '';
  concept := nil;
  celestialKind := nil;
  superior := nil;
  essencePoints := 0;
  dissonancePoints := 0;

  FForces[0] := TCorporealForces.Create;
  FForces[1] := TEtherealForces.Create;
  FForces[2] := TCelestialForces.Create;

  distinctions := TObjectList.Create(False);
  resources := TObjectList.Create(False);
end;

destructor TInNomineCharacter.Destroy;
begin
  freeAndNil(FForces[0]);
  freeAndNil(FForces[1]);
  freeAndNil(FForces[2]);
  freeAndNil(resources);
end;

function TInNomineCharacter.getAgility: TAttributeValue;
begin
  Result := TCorporealForces(FForces[0]).agility;
end;

function TInNomineCharacter.getForces(index: integer): TForces;
begin
  Result := FForces[index];
end;

function TInNomineCharacter.getIntelligence: TAttributeValue;
begin
  Result := TEtherealForces(FForces[1]).intelligence;
end;

function TInNomineCharacter.getNumberForces(): integer;
begin
  Result := FForces[0].number + FForces[1].number + FForces[2].number;
end;

function TInNomineCharacter.getPerception: TAttributeValue;
begin
  Result := TCelestialForces(FForces[2]).perception;
end;

function TInNomineCharacter.getPrecision: TAttributeValue;
begin
  Result := TEtherealForces(FForces[1]).precision;
end;

function TInNomineCharacter.getStrength: TAttributeValue;
begin
  Result := TCorporealForces(FForces[0]).strength;
end;

function TInNomineCharacter.getWill: TAttributeValue;
begin
  Result := TCelestialForces(FForces[2]).will;
end;

procedure TInNomineCharacter.setForces(index: Integer;
  const value: TForces);
begin
  FForces[index] := value;
end;

end.
